package StudyCode.summary.regularexpressionsmatch;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class MatchWordUsingRegex {
	private static final String REGEX = "\\bdog\\b";
	private static final String INPUT = "dog dog dog doggie dogg";

	public static void main(String[] args) {
		Pattern p = Pattern.compile(REGEX);
		Matcher m = p.matcher(INPUT);
		int count = 0;
		while (m.find()) {
			count++;
			System.out.println("匹配索引 " + count);
			System.out.println("开始(): " + m.start());
			System.out.println("结束(): " + m.end());
		}
	}
}
